-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1036 Add skip parameter to pagination plugin #2466
base: main
Are you sure you want to change the base?
#1036 Add skip parameter to pagination plugin #2466
Conversation
This PR adds an option to skip the first n items of a pagination. This allows usecases as described in 11ty#1036, where one might want to show the first n items on onether page and then paginate over the rest. Signed-off-by: Raphael Höser <[email protected]>
Signed-off-by: Raphael Höser <[email protected]>
The referenced PR adds the skip parameter and this one adds the required documentation. The "addedin" will probably need to be updated once the referenced PR got merged. Signed-off-by: Raphael Höser <[email protected]>
Huh! So this is like a start index? |
Yeah right. Basically it's a wrapper around |
Do we need test(s) for |
@pdehaan I added only one happy path and one sad path test for skip in this PR. Also the behavior is described in the docs PR: 11ty/11ty-website#1440 |
The referenced PR adds a magic string for content dates to use "git created" as the first time the file was created in git. Signed-off-by: Raphael Höser <[email protected]>
Personally I'm unsure about the name 'skip'. FWIW there's a few other related options pagination could have - start index, end index, count. I've had a few cases where I've wanted to limit or truncate my set of options. One possible way of supporting all of these could be for a |
@edwardhorsford Ahh, that might be a good idea. I came from the point of the SQL "SKIP" command. My first suggestion would be something like this: range:
first: 3
last: -4
count: 5 Where negative values mean "from last", where "-1" means the last element similar to Array.at().
Additionally we could support a string value for range in the form of Rust Ranges, so |
@Snapstromegon yep, I had a similar thought - using negative numbers to count backwards for the end. I suspect your first example with an object and properties is easier to read and understand than the Rust ranges. I might suggest different names though... perhaps:
I suspect users would be unlikely to want to use both I speculate My main use for a limit so far has been where I'm working on a pagination file that outputs many hundreds of pages - but for development I only need a small number to test. My solution so far has been filtering the data with the |
@edwardhorsford I also think that What I personally disagree with, is that E.g. if I have this data: - zero
- one
- two
- three
- four
- five
- six
- seven And I'd do range:
start: 2
end: 4 Would I get |
This PR adds an option to skip the first n items of a pagination.
This allows usecases as described in #1036, where one might want to show the first n items on onether page and then paginate over the rest.
fixes #1036